/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * TrainingBook
 * Copyright (C) Arnaud Duval 2010 <arnaud.duval@gmail.com>
 * 
 * Projects is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Projects is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _ACTIVITY_HPP_
#define _ACTIVITY_HPP_

#include <string>
#include <fstream>

#include <ActivityHeader.hpp>
#include <ActivityHistory.hpp>
#include <DateTime.hpp>
#include <Duration.hpp>
#include <libxml++/libxml++.h>

#define COEF_FOR_I1 1.
#define COEF_FOR_I2 2.
#define COEF_FOR_I3 3.5
#define COEF_FOR_I4 5.
#define COEF_FOR_I5 7.
#define COEF_FOR_I6 9.
#define COEF_FOR_I7 10.

///@class Activity
///@brief Defines an activity
class Activity
{
    public:
        ///@brief Default constructor
        Activity();
        ///@brief Copy contructor
        Activity(const Activity&);
        ///@brief Destructor
        ~Activity();
        ///@brief Overload of = operator
        Activity &operator=(const Activity&);
        ///@brief Load track from a GPX file
        void LoadGPX(std::string);
        ///@brief Read informations from a XML node
        void ReadXMLNode(xmlpp::Node*);
        ///@brief Write to XML file
        void WriteXML(std::ofstream&);

        //Getters
        ///@brief Return distance value
        double GetDistance();
        ///@brief Duration value
        Duration GetDuration();
        ///@brief Return date time value
        DateTime GetDateTime() const;
        ///@brief Return FC Max value
        int GetFCMax();
        ///@brief Return FC Moy value
        int GetFCMoy();
        ///@brief Return the type of activity
        std::string GetActivityType();
        ///@brief Return the location value
        std::string GetLocation();
        ///@brief Return the comments
        std::string GetComments();
        ///@brief Return the consumed calories
        unsigned int GetCalories();
        ///@brief Return the trained quality
        std::string GetQuality();
        ///@brief Return training load
        double GetTrainingLoad();
        ///@brief Return activity header
        ActivityHeader GetHeader();
        ///@brief Return activity history
        ActivityHistory GetHistory();
        ///@brief Return the average cadence
        unsigned int GetAverageCadence();
        ///@brief Return the average power
        double GetAveragePower();

        //Setters
        ///@brief Set the type of activity
        void SetActivityType(std::string);
        ///@brief Set the distance value
        void SetDistance(double);
        ///@brief Set the duration value
        void SetDuration(Duration);
        ///@brief Set the FC Moy value
        void SetFCMoy(int);
        ///@brief Set the FC Max value
        void SetFCMax(int);
        ///@brief Set the date value
        void SetDateTime(DateTime);
        ///@brief Set the location value
        void SetLocation(std::string);
        ///@brief Set the comments
        void SetComments(std::string);
        ///@brief Set the consumed calories value
        void SetCalories(unsigned int);
        ///@brief Set the trained quality
        void SetQuality(std::string);
        ///@brief Set the distance from values contained in the GPS track
        void SetDistanceFromTrack();
        ///@brief Set the duration from values contained in the GPS track
        void SetDurationFromTrack();
        ///@brief Set the header of the activity
        void SetHeader(ActivityHeader);
        ///@brief Set the history of the activity
        void SetHistory(ActivityHistory);
        
        ///@brief Recompute the average power from history
        bool RecomputeAveragePower();

        ///@brief Overload of < operator to sort activities depending on their date
        friend bool operator < (const Activity& , const Activity &);

    protected:

    private:
        ///@brief Header with informations on the activity
        ActivityHeader header;
        ///@brief History with recorded data
        ActivityHistory history;
        

};

#endif // _ACTIVITY_HPP_
